package com.example.android.wifidirect.VideoDownload;
 
import android.app.Activity;
import android.app.DownloadManager;
import android.app.DownloadManager.Query;
import android.app.DownloadManager.Request;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ImageView;
 
public class DownloadManager2 extends Thread {
    private long enqueue;
    private DownloadManager dm;
    DownloadManager.Request request;
   
    
 
    public void  download(String address)
    {
     String download_address = address.toString();
    Uri uri = Uri.parse(download_address);
    request  = new Request(uri);
    long reference = dm.enqueue(request);
    
    
 }
    public void define_allowed_network (String flags)
    {
    if(flags.equals("WIFI")) 
    request.setAllowedNetworkTypes(Request.NETWORK_WIFI);  
    
    if(flags.equals("LTE"))
    request.setAllowedNetworkTypes(Request.NETWORK_MOBILE);  

   }

   public void setDestination ()
   {

   request.setDestinationInExternalPublicDir("D2D DEMO", "video1.mp4");

   }
 
       
 /*
    public void onClick(View view) {
        dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        Request request = new Request(
                Uri.parse("http://www.vogella.de/img/lars/LarsVogelArticle7.png"));
        enqueue = dm.enqueue(request);
 
    }
 
    public void showDownload(View view) {
        Intent i = new Intent();
        i.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
        startActivity(i);
    }
    */
}



